﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Jim.SHR;

[System.Diagnostics.DebuggerStepThrough()]
[System.CodeDom.Compiler.GeneratedCode("Microsoft.Tools.ServiceModel.Svcutil", "2.0.3-preview3.21351.2")]
public partial class EASLoginProxyClient : System.ServiceModel.ClientBase<EASLoginProxy>, EASLoginProxy
{

    /// <summary>
    /// 实现此分部方法，配置服务终结点。
    /// </summary>
    /// <param name="serviceEndpoint">要配置的终结点</param>
    /// <param name="clientCredentials">客户端凭据</param>
    static partial void ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint, System.ServiceModel.Description.ClientCredentials clientCredentials);

    public EASLoginProxyClient() :
            base(GetDefaultBinding(), GetDefaultEndpointAddress())
    {
        Endpoint.Name = EndpointConfiguration.EASLogin.ToString();
        ConfigureEndpoint(Endpoint, ClientCredentials);
    }

    public EASLoginProxyClient(EndpointConfiguration endpointConfiguration) :
            base(GetBindingForEndpoint(endpointConfiguration), GetEndpointAddress(endpointConfiguration))
    {
        Endpoint.Name = endpointConfiguration.ToString();
        ConfigureEndpoint(Endpoint, ClientCredentials);
    }

    public EASLoginProxyClient(EndpointConfiguration endpointConfiguration, string remoteAddress) :
            base(GetBindingForEndpoint(endpointConfiguration), new System.ServiceModel.EndpointAddress(remoteAddress))
    {
        Endpoint.Name = endpointConfiguration.ToString();
        ConfigureEndpoint(Endpoint, ClientCredentials);
    }

    public EASLoginProxyClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) :
            base(GetBindingForEndpoint(endpointConfiguration), remoteAddress)
    {
        Endpoint.Name = endpointConfiguration.ToString();
        ConfigureEndpoint(Endpoint, ClientCredentials);
    }

    public EASLoginProxyClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
            base(binding, remoteAddress)
    {
    }

    [EditorBrowsable(EditorBrowsableState.Advanced)]
    Task<loginResponse> EASLoginProxy.loginAsync(loginRequest request)
    {
        return Channel.loginAsync(request);
    }

    public Task<loginResponse> loginAsync(string userName, string password, string slnName, string dcName, string language, int dbType)
    {
        loginRequest inValue = new loginRequest();
        inValue.userName = userName;
        inValue.password = password;
        inValue.slnName = slnName;
        inValue.dcName = dcName;
        inValue.language = language;
        inValue.dbType = dbType;
        return ((EASLoginProxy)this).loginAsync(inValue);
    }

    [EditorBrowsable(EditorBrowsableState.Advanced)]
    Task<logoutResponse> EASLoginProxy.logoutAsync(logoutRequest request)
    {
        return Channel.logoutAsync(request);
    }

    public Task<logoutResponse> logoutAsync(string userName, string slnName, string dcName, string language)
    {
        logoutRequest inValue = new logoutRequest();
        inValue.userName = userName;
        inValue.slnName = slnName;
        inValue.dcName = dcName;
        inValue.language = language;
        return ((EASLoginProxy)this).logoutAsync(inValue);
    }

    public virtual Task OpenAsync()
    {
        return Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)this).BeginOpen(null, null), new Action<IAsyncResult>(((System.ServiceModel.ICommunicationObject)this).EndOpen));
    }

    public virtual Task CloseAsync()
    {
        return Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)this).BeginClose(null, null), new Action<IAsyncResult>(((System.ServiceModel.ICommunicationObject)this).EndClose));
    }

    private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration)
    {
        if (endpointConfiguration == EndpointConfiguration.EASLogin)
        {
            System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
            result.MaxBufferSize = int.MaxValue;
            result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
            result.MaxReceivedMessageSize = int.MaxValue;
            result.AllowCookies = true;
            return result;
        }
        throw new InvalidOperationException(string.Format("找不到名称为“{0}”的终结点。", endpointConfiguration));
    }

    private static System.ServiceModel.EndpointAddress GetEndpointAddress(EndpointConfiguration endpointConfiguration)
    {
        if (endpointConfiguration == EndpointConfiguration.EASLogin)
        {
            return new System.ServiceModel.EndpointAddress("http://192.168.80.20:8080/ormrpc/services/EASLogin");
        }
        throw new InvalidOperationException(string.Format("找不到名称为“{0}”的终结点。", endpointConfiguration));
    }

    private static System.ServiceModel.Channels.Binding GetDefaultBinding()
    {
        return GetBindingForEndpoint(EndpointConfiguration.EASLogin);
    }

    private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress()
    {
        return GetEndpointAddress(EndpointConfiguration.EASLogin);
    }

    public enum EndpointConfiguration
    {

        EASLogin,
    }
}
